package other;


import javax.swing.JFrame;
import javax.swing.JPanel;

import builder.FormBuilder;
import builder.FormDirector;
import builder.AccountFormBuilderPackage.AccountFormBuilder;
import builder.AccountFormBuilderPackage.LoginDecorator;


public class AssetRegistryFrame extends JFrame {

	/**
	 * Launch the application.
	 */

	/**
	 * Create the frame.
	 */
    JPanel panel;
    private static AssetRegistryFrame arFrame;
    
    public static AssetRegistryFrame getARFrame(){
    	if(arFrame== null){
    		arFrame = new AssetRegistryFrame();
    	}
    	return arFrame;
    }
    
	public AssetRegistryFrame() {
        initialize();      
        setFrame();
	}
	
    private void initialize(){
   
		FormBuilder loginbuilder = new AccountFormBuilder();
		loginbuilder = new LoginDecorator(loginbuilder);
		FormDirector logindirector = new FormDirector(loginbuilder);
		logindirector.construct();
		panel =  logindirector.getForm();
		
    	this.changePanel(panel);
    	/*
    	ArrayList<MainMenuContent> contentList = FormCreator.createMainMenuContentList(FormCreator.ASSET_MANAGER);
		
		//this.changePanel(contentList.get(0).getPanel());
    	//this.changePanel(new MenuUI());
    	 * */
    	 
    }

    private void addToFrame(){
        getContentPane().add(panel);
        this.repaint();      
    }

    private void setBounds(){
        panel.setBounds(0, 0, panel.getWidth(), panel.getHeight());
    }

    private void setFrame(){
        this.setTitle("Asset Registry");
        this.setSize(800, 600);
        this.setVisible(true);
        //this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public void changePanel(JPanel newpanel){
    	if(this.panel!=null)
    		this.remove(this.panel);
        this.panel = newpanel;
        panel.setBounds(0, 0,800, 600);
        getContentPane().add(this.panel);
        this.repaint();    
        this.setVisible(true);
    }

}
